package arithmetic2.test;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @Author: 姚凤桥
 * @Date: 2022/3/27 21:28
 * @Description:
 */
public class Demo03 {
    private static int score = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        int[] arr = new int[n];
        String[] strs = sc.nextLine().split(" ");
        int index = 0;
        for (String str : strs) {
            arr[index++] = Integer.parseInt(str);
        }

        System.out.println(m(arr));
    }

    public static int m(int[] arr) {
        while (true) {
            //找到最长的相等区域
            List<String> ranges = m0(arr);
            //选择最优的区间
            for (String range : ranges) {
                String[] s = range.split(" ");
                int temp = m1(arr, Integer.parseInt(s[0]), Integer.parseInt(s[1]), 0);

            }
            if (arr == null || arr.length == 0) {
                break;
            }
        }
        return score;
    }

    //找打数组中最长的相等区域
    public static List<String> m0(int[] arr) {
        if (arr.length == 1) {
            List<String> res = new ArrayList<>();
            res.add("0 0");
            return res;
        }

        List<String> ranges = new ArrayList<>();
        int maxLen = 0;
        int index1 = 0;
        int index2 = 1;
        while (index2 < arr.length) {
            //如果当前数和前一个数相等，end++
            if (arr[index2] == arr[index2 - 1]) {
                index2++;
            } else {
                //碰到了不相同的数
                if (maxLen < index2 - index1) {
                    maxLen = index2 - index1;
                    ranges.clear();
                    //记录区间
                    ranges.add(index1 + " " + (index2 - 1));
                } else if (maxLen == index2 - index1) {
                    ranges.add(index1 + " " + (index2 - 1));
                }
                index1 = index2;
                index2++;
            }
        }

        if (maxLen == 0) {
            ranges.add("0 " + (arr.length - 1));
        }

        //筛选出最长的区间

        return ranges;
    }

    //返回分数
    public static int m1(int[] arr, int start, int end, int temp) {
        int[] res = new int[arr.length - end + start - 1];
        int index = 0;
        for (int i = 0; i < arr.length; i++) {
            if (i < start || i > end) {
                res[index++] = arr[i];
            }
        }
        temp += (end - start + 1) * (end - start + 1);
        return temp;
    }
}
